Skip to content

fix(canvas): Windows font fallback and WebGPU canvases as WebGL sources - #258

Open
triniwiz wants to merge 1 commit into
masterfrom
fix/windows-text-webgpu-sources
Open

triniwiz wants to merge 1 commit into
masterfrom
fix/windows-text-webgpu-sources

Conversation

@triniwiz

Copy link
Copy Markdown
Member

Fixes the canvas spec failures that remained on Windows.

Change

Font fallback (canvas-2d, Windows only). DirectWrite has no family named serif, sans-serif or monospace, and when no family matches, SkParagraph falls back to the last font the page registered, so text in an unknown family drew in a web font. Font::skia_families() maps the CSS generics to Chrome's Windows defaults (Times New Roman, Arial, Consolas, Comic Sans MS, Impact, Segoe UI) and ends the list with Times New Roman, Chrome's standard font. Other platforms are unchanged.

WebGPU canvas as a WebGL texture source (Node-API hosts). texImage2D (both forms) and texSubImage2D passed a WebGPU canvas's context object itself, which the binding rejects. They now pass it as a canvas source ({ __native__context }), the form the binding takes for WebGPU since #191.

Specs

  • audio: the offline oscillator expects web-audio-api 1.8.0's normalized square level (RMS 0.415), as the Node test has since test(audio): expect the spec-normalized square level from web-audio-api 1.8.0 #207.
  • webgpu.canvas present timing: measured from the first poll. NativeScript Windows runs timers once a frame, before the rAF callbacks, so a setTimeout(0) queued in a rAF callback first runs a frame later. The present itself happens in the frame's microtask flush, under a millisecond after drawing. A present at the next vsync still fails the check.

Verified

  • Windows 11 (Intel Iris Xe): the full canvas spec suite, all passing (with feat(canvas): draw NativeScript views into a canvas on Windows #257).
  • Plain Node on Windows: after registering Creepster, a missing family measures as Times New Roman (192.19 px for "Hello world" at 40 px) instead of Creepster (180.23 px); serif, sans-serif and monospace measure as Times New Roman, Arial and Consolas.
  • cargo check -p canvas-2d on macOS.

Fonts: DirectWrite knows no family named serif, sans-serif or
monospace, and when nothing matches, SkParagraph falls back to the last
font a page registered, so text in an unknown family drew in a web
font. On Windows the CSS generics now map to Chrome's defaults (Times
New Roman, Arial, Consolas, ...), and Times New Roman, Chrome's
standard font, ends every family list.

WebGL: texImage2D (both forms) and texSubImage2D passed a WebGPU
canvas's GPUCanvasContext itself, which the Node-API binding rejects.
They now pass it as a canvas source, as the binding expects.

Specs: the offline oscillator expects web-audio-api 1.8.0's normalized
square level, as the Node test does since #207. The WebGPU present
timing check measures from its first poll, because NativeScript
Windows runs timers once a frame, so the first poll can itself land a
frame after drawing; a present at the next vsync still fails it.
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1b992866-64a8-4d68-a54a-0348d6665c46

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant